<table class="table table-hover">
    <thead>
        <tr>
            <th>发货单号</th>
            <th>销售员</th>
            <th>目的仓库</th>
            <th>站点</th>
            <th>状态</th>
            <th>运输状态</th>
            <th style="max-width: 200px;">备注</th>
            <th>发货时间</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach($paginator as $row)
            <tr>
                <td>{{ $row->delivery_no }}</td>
                <td>{{ \App\Util\User::getUsernameById($row->seller_id) }}</td>
                <td>{{ $row->warehouse->w_code ?? '' }}</td>
                <td>{{ $row->area->area ?? '' }}</td>
                <td>{{ \App\Models\OverSeasIn\Delivery::$_status[$row->status] }}</td>
                <td>
                    <a href="javascript:void(0)" class="list-modal" data-id="{{ $row->id }}" data-action="listCheckTransport">
                        {{ \App\Models\OverSeasIn\Delivery::$_transportStatus[$row->transport_status] }}
                    </a>
                </td>
                <td>{{ $row->remarks }}</td>
                <td>{{ $row->delivered_at }}</td>
                <td>
                    @if(\Encore\Admin\Facades\Admin::user()->isRole('salesperson') && \Encore\Admin\Facades\Admin::user()->id != $row->seller_id)
                        @if(\Encore\Admin\Facades\Admin::user()->can('os-in.os.os-track-ex'))
                            <a href="/xqc/overseas-in/os-track-ex/{{ $row->id }}" class="btn btn-xs btn-primary">查看</a>
                        @endif
                    @else
                        @if(\Encore\Admin\Facades\Admin::user()->can('os-in.os.os-track-ex'))
                            <a href="/xqc/overseas-in/os-track-ex/{{ $row->id }}" class="btn btn-xs btn-primary">查看</a>
                        @endif
                        @if($row->status >= 6 && \Encore\Admin\Facades\Admin::user()->can('os-in.os.os-track-ex-do'))
                            <button class="btn btn-xs btn-info list-logistics-modal" data-id="{{ $row->id }}" data-action="listLogistics">更新物流</button>
                        @endif
                    @endif
                </td>
            </tr>
        @endforeach
    </tbody>
</table>
<!--操作预览Modal -->
<div class="modal fade" id="listModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog" style="width: 60%;">
        <div class="modal-content">
            <!-- 内容会加载到这里 -->
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--更新物流Modal -->
<div class="modal fade" id="listLogisticsModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- 内容会加载到这里 -->
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script language="JavaScript" type="text/javascript">
    $(function () {
        //更新物流
        $('.list-logistics-modal').on('click', function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            var action = $(this).data('action');
            $("#listLogisticsModal").modal({
                remote : '/xqc/overseas-in/os-modal?action=' + action + '&param=' + id
            });
        });
        $("#listLogisticsModal").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();
        });

        //操作预览Modal
        $('.list-modal').on('click', function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            var action = $(this).data('action');
            $("#listModal").modal({
                remote : '/xqc/overseas-in/os-modal?action=' + action + '&param=' + id
            });
        });
        $("#listModal").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();
        });
    });
</script>
